package com.upic.serviceImpl;

import com.upic.po.jurisdiction.OperatorRole;
import com.upic.repository.OperatorRoleRepository;
import com.upic.service.OperatorRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by zhubuqing on 2018/2/7.
 */
@Service("operatorRoleService")
public class OperatorRoleServiceImpl implements OperatorRoleService {
    @Autowired
    private OperatorRoleRepository operatorRoleRepository;

    @Override
    public OperatorRole saveOperatorRole(OperatorRole operatorRole) {
        return operatorRoleRepository.save(operatorRole);
    }

    @Override
    public String deleteOperatorRole(long operatorRoleId) {
        operatorRoleRepository.delete(operatorRoleId);
        return "SUCCESS";
    }

    @Override
    public Page<OperatorRole> searchOperatorRole(Pageable pageable) {
        return operatorRoleRepository.findAll(pageable);
    }

    @Override
    public List<OperatorRole> searchOperatorRole() {
        return operatorRoleRepository.findAll();
    }

    @Override
    public OperatorRole findOne(long operatorRoleId) {
        return operatorRoleRepository.findOne(operatorRoleId);
    }

    @Override
    public OperatorRole updateOperatorRole(OperatorRole operatorRole) {
        return operatorRoleRepository.saveAndFlush(operatorRole);
    }
}
